/*
 Copyright (C) 2008  Maurizio Monticelli

 This program is free software; you can redistribute it and/or modify it under the terms of the 
 GNU General Public License as published by the Free Software Foundation; either version 2 of the 
 License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
 even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 
 Public License for more details.

 You should have received a copy of the GNU General Public License along with this program; if not, write 
 to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 
*/

package ch.justdoit.andriodrpncalc.view.buttons;

import java.util.ArrayList;

import ch.justdoit.andriodrpncalc.model.Model;
import ch.justdoit.andriodrpncalc.model.Settings;
import android.content.Context;
import android.view.View;

public class ButtonNumberBase extends BaseButton {

	private ArrayList<String> bases;
	private int position;

	public ButtonNumberBase(Context context, Model _model) {
		super(context, _model);
		position = 0;
		setTextSize((float) (0.3 * HEIGHT));
		setOnClickListener(onClickListener);
		bases = new ArrayList<String>();
		bases.add("base:\ndec");
		bases.add("base:\nbin");
		bases.add("base:\noct");
		bases.add("base:\nhex");
		setPostion();
	}

	private void setPostion() {
		switch (position) {
		case 0:
			mModel.mSettings.setDisplayBase(Settings.BASE.DEC);
			break;
		case 1:
			mModel.mSettings.setDisplayBase(Settings.BASE.BIN);
			break;
		case 3:
			mModel.mSettings.setDisplayBase(Settings.BASE.HEX);
			break;
		case 2:
			mModel.mSettings.setDisplayBase(Settings.BASE.OCT);
			break;

		}
		setText(bases.get(position));
	}

	private OnClickListener onClickListener = new OnClickListener() {

		@Override
		public void onClick(View arg0) {
			if (false) {
			position++;
			position = position % bases.size();
			setPostion();
			} else {
				mModel.setErrorMessage("Base not implemented");
			}
			
		}

	};

}
